home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / misc / amoricv0.lha / AmoricV0_8a / src / runtime_020.asm < prev    next >
Assembly Source File  |  1995-10-09  |  4KB  |  208 lines

  1. ; *** ORIC Emulator. Amiga Version 680x0 ***
  2. ; *** Copyright 1995/96 JF FABRE ***
  3. ; *** Main program ***
  4.  
  5. ; d1.b : A
  6. ; d2.b : X
  7. ; d3.b : Y
  8. ; d4.b : P
  9. ; d5.b : S
  10. ; D6   : **scratch**
  11. ; D7   : **scratch**
  12.  
  13. ; a0.l : Mem Ptr
  14. ; a1.l : Mem Ptr + $304
  15. ; a2.l : Functable pour les instructions
  16. ; a3.l : Pointeur sur diverses tables
  17. ; a4.l : PC+Base Adr
  18. ; a5.l : Retour apres traitement d'instruction
  19. ; a6.l : **Scratch**
  20.  
  21.     MACHINE    68020
  22.  
  23.         XDEF    _RunOric        ; C
  24.         XDEF    _ReturnToMonitor
  25.     XDEF    _StepOric        ; C
  26.     XDEF    _HandleCtrl
  27.     XDEF    _MainLoop
  28.     XDEF    _MainLoopReload
  29.  
  30.     XDEF    _BreakReason
  31.                
  32.         XREF    _InitKbTableOnce
  33.     XREF    _InitFonctions
  34.         XREF    _IRQ
  35.         XREF    _RegistersToMem
  36.         XREF    _MemToRegisters
  37.     XREF    _RefreshScreen
  38.     XREF    _RewindTapeLoadAsm
  39.  
  40.     XREF    _RefreshScr
  41.     XREF    _ShowHelp
  42.  
  43.     XREF    _CtrlKeyPressed
  44.     XREF    _KeyF10Lock
  45.  
  46.     XREF    _UserLoadT1
  47.     XREF    _UserLoadT2
  48.  
  49.         XREF    _M
  50.         XREF    _A
  51.         XREF    _X
  52.         XREF    _Y
  53.         XREF    _S
  54.         XREF    _P
  55.         XREF    _PC
  56.   
  57. NB_CYCLE = 4
  58.    
  59.         include "my_defs.i"
  60.     include    "my_macros.asm"
  61.  
  62.         
  63. ; *** Programme principal ***
  64.  
  65.     
  66. _RunOric:            ; Point d'entree du C
  67. @RunOric:
  68.         STORE_REGS
  69.         jsr     _MemToRegisters
  70.     clr.b    _KeyF10Lock
  71. _MainLoopReload:
  72.     lea    _MainLoop(PC),A5
  73. _MainLoop:
  74.     ;*** Horloge Timer 1
  75.  
  76. Timer1:
  77.     subq.b    #NB_CYCLE,(A1)    ; 3 = Nb de Cycles moyen par instruction
  78.     bcs.b    Dec305
  79. Timer2:
  80.     subq.b    #NB_CYCLE,4(A1)        ; 4 = Nb de Cycles moyen par instruction
  81.     bcs.b    Dec309
  82.  
  83. ProcessInst:
  84.     moveq.l    #0,D6
  85.     move.b    (A4)+,D6    ; Incrementation de 1 de A4 = PC++    
  86.     move.l    (A2,D6.W*4),A6
  87.     jmp    (A6)
  88.  
  89. Dec305:
  90.     subq.b    #1,1(A1)
  91.     bne.b    Timer2
  92.  
  93. T1Int:
  94.     move.w    $2(A1),(A1)    ; Rechargement des cellules
  95.     btst    #6,$7(A1)    ; Test du bit 6 de $30B -> Si 1 : Interruptions Continues
  96.     bne.b    T1DoInt        ; Si 0 : Interruptions uniquement lors d'un load
  97.  
  98.     tst.b    _UserLoadT1
  99.     beq.b    Timer2
  100.     clr.b    _UserLoadT1
  101.  
  102. T1DoInt:
  103.  
  104.     bset    #6,$9(A1)    ; Met le bit 6 de $30D a 1
  105.     move.b    $A(A1),D6    ; $30E
  106.     bpl.b    Timer2        ; bit 7 de 0x30E
  107.     and.b    $9(A1),D6    ; Test $30D avec $30E
  108.     beq.b    Timer2
  109.     TST_PB    I_BIT
  110.     bne.b    Timer2        ; Interruptions masquees : Ne fait rien
  111.     CLR_PB    B_BIT
  112.     jmp    _IRQ        ; Saut a l'interruption IRQ
  113.  
  114.  
  115. Dec309:
  116.     subq.b    #1,5(A1)
  117.     bne.b    ProcessInst
  118.  
  119. T2Int:
  120.     move.w    #$FFFF,4(A1)
  121.     tst.b    _UserLoadT2
  122.     beq.b    ProcessInst
  123.     clr.b    _UserLoadT2
  124.  
  125.     bset    #5,$9(A1)    ; Met le bit 5 de $30D a 1
  126.     move.b    $A(A1),D6    ; $30E
  127.     bpl.b    ProcessInst    ; bit 7 de 0x30E
  128.     and.b    $9(A1),D6    ; Test $30D avec $30E
  129.     beq.b    ProcessInst
  130.     TST_PB    I_BIT
  131.     bne.b    ProcessInst    ; Interruptions masquees : Ne fait rien
  132.     CLR_PB    B_BIT
  133.     jmp    _IRQ        ; Saut a l'interruption IRQ
  134.     
  135.  
  136. _StepOric:            ; Point d'entree du C
  137.     STORE_REGS
  138.     jsr    _MemToRegisters
  139.     lea    _ReturnToMonitor(PC),A5
  140.     move.b    #STEP_COMMAND,_BreakReason
  141.     bra    _MainLoop    ; Ensuite, ca reviendra a _ReturnToMonitor
  142.  
  143.  
  144. _ReturnToMonitor:    
  145.     
  146.     jsr    _RegistersToMem
  147.     RESTORE_REGS
  148.         
  149.     moveq.l    #0,D0
  150.         move.b  _BreakReason(PC),D0
  151.         rts     ; Retour au C (moniteur)
  152.         
  153. BreakReq:
  154.     move.b    #USER_BREAK,_BreakReason
  155.     bra.b    _ReturnToMonitor
  156.  
  157. ChtLoad:
  158.     move.b    #CHANGE_TAPE,_BreakReason
  159.     bra.b    _ReturnToMonitor
  160.  
  161. _HandleCtrl:
  162.     move.b    _CtrlKeyPressed,D6
  163.     clr.b    _CtrlKeyPressed
  164.     andi.w    #$FF,D6
  165.     subq.w    #1,D6
  166.     lea    ControlTable(PC),A6
  167.     move.l    (A6,D6.W*4),A6
  168.     jmp    (A6)
  169.  
  170. WarmReset:
  171.     moveq.l    #0,D6
  172.     moveq.l    #0,D6
  173.     move.w    #$FFFA,D6
  174.     move.b    1(A0,D6.L),D0
  175.     lsl.w    #8,D0
  176.     move.b    (A0,D6.L),D0
  177.     move.l    A0,A4
  178.     add.l    D0,A4
  179.     bra    _MainLoopReload
  180.  
  181. ColdReset:
  182.     moveq.l    #0,D6
  183.     moveq.l    #0,D0
  184.     move.w    #$FFFC,D6
  185.     move.b    1(A0,D6.L),D0
  186.     lsl.w    #8,D0
  187.     move.b    (A0,D6.L),D0
  188.     move.l    A0,A4
  189.     add.l    D0,A4
  190.     bra    _MainLoopReload
  191.  
  192.  
  193. HotRewind:
  194.     jsr    _RewindTapeLoadAsm
  195.     bra    _MainLoopReload
  196.     
  197.  
  198. _BreakReason:
  199.     dc.b    0
  200.     even
  201.  
  202. ControlTable:
  203.     dc.l    WarmReset,_RefreshScr,ChtLoad,_MainLoopReload,ColdReset
  204.     dc.l    _MainLoopReload,HotRewind,_MainLoopReload,_MainLoopReload,BreakReq
  205.     dc.l    _MainLoopReload,_MainLoopReload,_MainLoopReload
  206.     dc.l    _MainLoopReload,_MainLoopReload,_ShowHelp
  207.  
  208.